﻿<html>

<head>
  <title>Settings</title>
  <link rel="stylesheet" type="text/css" href="../popups/popup.css" />
  <script type="text/javascript">

function getAbsolutePos(el) {
  var r = { x: el.offsetLeft, y: el.offsetTop };
  if (el.offsetParent)
  {
    var tmp = getAbsolutePos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
  }
  return r;
};

function getSelectedValue(el) {
  if(!el)
    return "";
  return el[el.selectedIndex].value;
}

function setSelectedValue(el, val) {
  if(!el)
    return "";
  var ops = el.getElementsByTagName("option");
  for (var i = ops.length; --i >= 0;) {
    var op = ops[i];
    op.selected = (op.value == val);
  }
  el.value = val;
}

function getCheckedValue(el) {
  if(!el)
    return "";
  var radioLength = el.length;
  if(radioLength == undefined)
    if(el.checked)
      return el.value;
    else
      return "false";
  for(var i = 0; i < radioLength; i++) {
    if(el[i].checked) {
      return el[i].value;
    }
  }
  return "";
}

function setCheckedValue(el, val) {
  if(!el)
    return;
  var radioLength = el.length;
  if(radioLength == undefined) {
    el.checked = (el.value == val.toString());
    return;
  }
  for(var i = 0; i < radioLength; i++) {
    el[i].checked = false;
    if(el[i].value == val.toString()) {
      el[i].checked = true;
    }
  }
}

function __dlg_onclose() {
  opener.Dialog._return(null);
};

// closes the dialog and passes the return info upper.
function __dlg_close(val) {
  opener.Dialog._return(val);
  window.close();
};

function __dlg_close_on_esc(ev) {
  ev || (ev = window.event);
  if (ev.keyCode == 27) {
    window.close();
    return false;
  }
  return true;
};

function __dlg_init(bottom) {
  var body = document.body;
  var body_height = 0;
  if (typeof bottom == "undefined") {
    var div = document.createElement("div");
    body.appendChild(div);
    var pos = getAbsolutePos(div);
    body_height = pos.y;
  } else {
    var pos = getAbsolutePos(bottom);
    body_height = pos.y + bottom.offsetHeight;
  }
  window.dialogArguments = opener.Dialog._arguments;
  if (!document.all) {
    window.sizeToContent();
    window.sizeToContent();  // for reasons beyond understanding,
          // only if we call it twice we get the
          // correct size.
    window.addEventListener("unload", __dlg_onclose, true);
    window.innerWidth = body.offsetWidth + 5;
    window.innerHeight = body_height + 2;
    // center on parent
    var x = opener.screenX + (opener.outerWidth - window.outerWidth) / 2;
    var y = opener.screenY + (opener.outerHeight - window.outerHeight) / 2;
    window.moveTo(x, y);
  } else {
    // window.dialogHeight = body.offsetHeight + 50 + "px";
    // window.dialogWidth = body.offsetWidth + "px";
    window.resizeTo(body.offsetWidth, body_height);
    var ch = body.clientHeight;
    var cw = body.clientWidth;
    window.resizeBy(body.offsetWidth - cw, body_height - ch);
    var W = body.offsetWidth;
    var H = 2 * body_height - ch;
    var x = (screen.availWidth - W) / 2;
    var y = (screen.availHeight - H) / 2;
    window.moveTo(x, y);
  }
  document.body.onkeypress = __dlg_close_on_esc;
};

function placeFocus() {
var bFound = false;
  // for each form
  for (f=0; f < document.forms.length; f++) {
    // for each element in each form
    for(i=0; i < document.forms[f].length; i++) {
      // if it's not a hidden element
      if (document.forms[f][i].type != "hidden") {
        // and it's not disabled
        if (document.forms[f][i].disabled != true) {
            // set the focus to it
            document.forms[f][i].focus();
            var bFound = true;
        }
      }
      // if found in this element, stop looking
      if (bFound == true)
        break;
    }
    // if found in this form, stop looking
    if (bFound == true)
      break;
  }
}

function Init() {
  __dlg_init();
  var param = window.dialogArguments;
  if(param) {
    var el;
    for (var field in param) {
      //alert(field + '="' + param[field] + '"');
      el = document.getElementById(field);
      if (el.tagName.toLowerCase()=="input"){
        if ((el.type.toLowerCase()=="radio") || (el.type.toLowerCase()=="checkbox")){
          setCheckedValue(el, param[field]);
        } else {
          el.value = param[field];
        }
      } else if (el.tagName.toLowerCase()=="select"){
        setSelectedValue(el, param[field]);
      } else if (el.tagName.toLowerCase()=="textarea"){
        el.value = param[field];
      }
    }
  }
  placeFocus();
};

// pass data back to the calling window
function onOK() {
  var param = new Object();
  var el = document.getElementsByTagName('input');
  for (var i=0; i<el.length;i++){
    if ((el[i].type.toLowerCase()=="radio") || (el[i].type.toLowerCase()=="checkbox")){
      if (getCheckedValue(el[i])!=''){
        param[el[i].id] = getCheckedValue(el[i]);
      }
    } else {
      param[el[i].id] = el[i].value;
    }
  }
  el = document.getElementsByTagName('select');
  for (var i=0; i<el.length;i++){
    param[el[i].id] = getSelectedValue(el[i]);
  }
  el = document.getElementsByTagName('textarea');
  for (var i=0; i<el.length;i++){
    param[el[i].id] = el[i].value;
  }
  __dlg_close(param);
  return false;
};

function onCancel() {
  __dlg_close(null);
  return false;
};

</script>

<style type="text/css">
  label { width: 16em; float: left; padding: 2px 5px; text-align: right; }
  br { clear: both; }
</style>

</head>

<body class="dialog" onload="Init(); window.resizeTo(420, 820);">
<div class="title">Settings</div>
  <form action="" method="get">
  <fieldset>
    <legend>Xinha options</legend>
    <label for="width">Editor width:</label>
    <input type="text" name="width" id="width" title="Allowed values are 'auto', 'toolbar' or a numeric value followed by 'px'." /><br />
    <label for="height">Editor height:</label>
    <input type="text" name="height" id="height" title="Allowed values are 'auto' or a numeric value followed by 'px'." /><br />
    <label for="sizeIncludesBars">Size includes bars</label>
    <input type="checkbox" name="sizeIncludesBars" id="sizeIncludesBars" value="true" title="Specifies whether the toolbar should be included in the size, or are extra to it." /><br />
    <label for="sizeIncludesPanels">Size includes panels</label>
    <input type="checkbox" name="sizeIncludesPanels" id="sizeIncludesPanels" value="true" title="Specifies whether the panels should be included in the size, or are extra to it." /><br />
    <label for="statusBar">Status Bar</label>
    <input type="checkbox" name="statusBar" id="statusBar" value="true" title="Enable creation of the status bar?" /><br />
    <label for="htmlareaPaste">Htmlarea Paste</label>
    <input type="checkbox" name="htmlareaPaste" id="htmlareaPaste" value="true" title="Intercept ^V and use the Xinha paste command" /><br />
    <label for="mozParaHandler">Mozilla Parameter Handler:</label>
    <select name="mozParaHandler" id="mozParaHandler" title="Gecko only: Let the built-in routine for handling the return key decide if to enter br or p tags or use a custom implementation.">
    <option value="built-in">built-in</option>
    <option value="dirty">dirty</option>
    <option value="best">best</option>
    </select><br />
    <label for="getHtmlMethod">GetHtml Method:</label>
    <select name="getHtmlMethod" id="getHtmlMethod" title="This determines the method how the HTML output is generated.">
    <option value="DOMwalk">DOMwalk</option>
    <option value="TransformInnerHTML">TransformInnerHTML</option>
    </select><br />
    <label for="undoSteps">Undo steps:</label>
    <input type="text" name="undoSteps" id="undoSteps" title="Maximum size of the undo queue."  /><br />
    <label for="undoTimeout">Undo Timeout:</label>
    <input type="text" name="undoTimeout" id="undoTimeout" title="The time interval at which undo samples are taken, default: 500 (1/2 sec)."  /><br />
    <label for="changeJustifyWithDirection">change justify with direction</label>
    <input type="checkbox" name="changeJustifyWithDirection" id="changeJustifyWithDirection" value="true" title="Set this to true if you want to explicitly right-justify when setting the text direction to right-to-left" /><br />
    <label for="fullPage">full Page</label>
    <input type="checkbox" name="fullPage" id="fullPage" value="true" title="If true then Xinha will retrieve the full HTML, starting with the HTML-tag." /><br />
    <label for="pageStyle">Page style:</label>
    <textarea name="pageStyle" id="pageStyle" title="Raw style definitions included in the edited document"></textarea>
<!--    pageStyleSheets -->
    <label for="baseHref">Base href:</label>
    <input type="text" name="baseHref" id="baseHref" title="specify a base href for relative links" /><br />
    <label for="expandRelativeUrl">expand relative Url</label>
    <input type="checkbox" name="expandRelativeUrl" id="expandRelativeUrl" value="true" title="If true, relative URLs (../) will be made absolute"/><br />
    <label for="stripBaseHref">Strip base href</label>
    <input type="checkbox" name="stripBaseHref" id="stripBaseHref" value="true" title="We can strip the server part out of URL to make/leave them semi-absolute" /><br />
    <label for="stripSelfNamedAnchors">Strip self named anchors</label>
    <input type="checkbox" name="stripSelfNamedAnchors" id="stripSelfNamedAnchors" value="true" title="We can strip the url of the editor page from named links" /><br />
    <label for="only7BitPrintablesInURLs">only 7bit printables in URLs</label>
    <input type="checkbox" name="only7BitPrintablesInURLs" id="only7BitPrintablesInURLs" value="true" title="In URLs all characters above ASCII value 127 have to be encoded using % codes" /><br />
    <label for="sevenBitClean">7bit Clean</label>
    <input type="checkbox" name="sevenBitClean" id="sevenBitClean" value="true" title="If you are putting the HTML written in Xinha into an email you might want it to be 7-bit characters only." /><br />
    <label for="killWordOnPaste">kill Word on paste</label>
    <input type="checkbox" name="killWordOnPaste" id="killWordOnPaste" value="true" title="Set to true if you want Word code to be cleaned upon Paste." /><br />
    <label for="makeLinkShowsTarget">make Link Shows Target</label>
    <input type="checkbox" name="makeLinkShowsTarget" id="makeLinkShowsTarget" value="true" title="Enable the 'Target' field in the Make Link dialog." /><br />
    <label for="flowToolbars">flow toolbars</label>
    <input type="checkbox" name="flowToolbars" id="flowToolbars" value="true" /><br />
    <label for="stripScripts">strip Scripts</label>
    <input type="checkbox" name="stripScripts" id="stripScripts" value="true" title="Set to false if you want to allow JavaScript in the content" /><br />
    <label for="showLoading">show loading</label>
    <input type="checkbox" name="showLoading" id="showLoading" value="true" /><br />
  </fieldset>

  <fieldset id="CharacterMapOptions" class="options">
    <legend>CharacterMap options</legend>
    <label for="CharacterMapMode">Mode :</label>
    <select id="CharacterMapMode" name="CharacterMapMode">
    <option value="popup">popup</option>
    <option value="panel">panel</option>
    </select>
  </fieldset>

  <fieldset id="ListTypeOptions" class="options">
    <legend>ListType options</legend>
    <label class="ListTypeMode">Mode :</label>
    <select id="ListTypeMode" name="ListTypeMode">
    <option value="toolbar">toolbar</option>
    <option value="panel">panel</option>
    </select>
  </fieldset>

  <fieldset id="CharCounterOptions" class="options">
    <legend>CharCounter options</legend>
    <label for="showChar">show Char :</label>
    <input type="checkbox" name="showChar" id="showChar" value="true" /><br />
    <label for="showWord">show Word :</label>
    <input type="checkbox" name="showWord" id="showWord" value="true" /><br />
    <label for="showHtml">show Html :</label>
    <input type="checkbox" name="showHtml" id="showHtml" value="true" /><br />
  </fieldset>
  <br />

  <div id="buttons">
    <button type="submit" name="ok" onclick="return onOK();">OK</button>
    <button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
  </div>
</form>
</body>
</html>
